import http from '@/common/js/httpRequest'

//方案
//保存或修改稳考方案
export function saveOrUpdateProject (data) {
	const url = !data.project.projectId ? '/api/base/stability/project/save' : '/api/base/stability/project/update'
  return http({
    method: 'post',
    url: url,
    data
  })
}

//获取稳考方案列表
export function getProjectList (params) {
  return http({
    method: 'get',
    url: '/api/base/stability/project/list',
    params
  })
}

//获取稳考方案数量by货品
export function getProjectCount (params) {
  return http({
    method: 'get',
    url: '/api/base/stability/project/count',
    params
  })
}

//获取稳考方案by货品
export function getStabilityProjectByProductId (params) {
  return http({
    method: 'get',
    url: '/api/base/stability/project/one',
    params
  })
}

//获取稳考方案相关信息
export function getProjectInfo (params) {
  return http({
    method: 'get',
    url: '/api/base/stability/project/info',
    params
  })
}

//根据考察方式获取时间默认配置
export function getModeTimeList (params) {
  return http({
    method: 'get',
    url: '/api/base/stability/modetime/list',
    params
  })
}

//获取考察方式列表
export function getStabilityModeList () {
  return http({
    method: 'get',
    url: '/api/base/stability/mode/list'
  })
}

//获取时间单位
export function getBaseTimeList () {
  return http({
    method: 'get',
    url: '/api/base/stability/time/list'
  })
}

//修改方案绑定的货品
export function updateProjectCollocate (data) {
  return http({
    method: 'post',
    url: '/api/base/stability/project/collocate',
    data
  })
}

//删除方案
export function deleteProject (ids) {
  return http({
    method: 'post',
    url: '/api/base/stability/project/delete',
    data: ids,
    openDefultdata: true
  })
}

//复制方案
export function copyProject (data) {
  return http({
    method: 'post',
    url: '/api/base/stability/project/copy',
    data
  })
}
//同步
export function syncStabilityProject (data) {
  return http({
    method: 'post',
    url: '/api/base/stability/project/sync',
    data
  })
}



//计划
//计划列表
export function stabilityPlanList (params) {
  return http({
    method: 'get',
    url: '/api/stability/plan/list',
    params
  })
}
//获取times and items
export function getTimeAndItemForPlan (params) {
  return http({
    method: 'get',
    url: '/api/stability/plan/times',
    params
  })
}
//获取标准和项目
export function getStandardAndItems (data) {
  return http({
    method: 'post',
    url: '/api/stability/plan/standard/info',
    data
  })
}
//保存或修改计划
export function saveOrUpdatePlan (data) {
  let url = !data.isUpdate ? '/api/stability/plan/save' : '/api/stability/plan/update'
  return http({
    method: 'post',
    url: url,
    data,
    openDefultdata: true
  })
}
//只领取
export function stabilityOnlyGet (data) {
  return http({
    method: 'post',
    url: '/api/stability/plan/get',
    data
  })
}
//只计划
export function stabilityOnlyPlan (data) {
  return http({
    method: 'post',
    url: '/api/stability/plan/plan',
    data,
    openDefultdata: true
  })
}
//获取此计划的取样记录
export function getInventoryBookByPlanId (params) {
  return http({
    method: 'get',
    url: '/api/stability/plan/book/byplanid',
    params
  })
}
//手动修改存库量
export function changeInventory (data) {
  return http({
    method: 'post',
    url: '/api/stability/plan/inventory/update',
    data,
    openDefultdata: true
  })
}
//删除计划
export function deletePlan(ids) {
  return http({
    method: 'post',
    url: '/api/stability/plan/delete',
    data: ids,
    openDefultdata: true
  })
}
//获取稳考台账
export function getTestBook (params) {
  return http({
    method: 'get',
    url: '/api/stability/plan/test/book',
    params
  })
}

//手工导入计划
export function importPlans(data) {
  return http({
    method: 'post',
    url: '/api/stability/plan/import',
    data,
    openDefultdata: true
  })
}

//修改取样时间的状态
export function updateStabilityTimeStatus(data) {
  return http({
    method: 'post',
    url: '/api/stability/plan/time/update',
    data
  })
}